package com.example.tao_city.spinnertext;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.TextView;

import java.util.List;

/**
 * Created by TAO_CITY on 2017/12/6.
 */

public class Textd extends BaseAdapter {
    private List<Parent> list;
    private Context context;
    public Textd(List list,Context context){
        this.list=list;
        this.context=context;
    }
    @Override
    public int getCount() {//返回listview的长度
        return list.size();
    }

    @Override
    public Object getItem(int i) {//返回指定的list view
        return list.get(i);
    }

    @Override
    public long getItemId(int i) {
        return i;
    }

    @Override
    public View getView(int i, View view, ViewGroup viewGroup) {//返回list view视图
        LayoutInflater layoutInflater=LayoutInflater.from(context);
        view=layoutInflater.inflate(R.layout.text1,null);
        if(view!=null){
            TextView textView1=(TextView)view.findViewById(R.id.ct1);
            ImageView imageView=(ImageView)view.findViewById(R.id.img1);
            textView1.setText(list.get(i).getCs1());
            imageView.setImageResource(list.get(i).getImg());

        }
        return view;
    }
}
